package com.fivestar.finance.app.ui.account;

import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.fivestar.finance.app.FFApplication;
import com.fivestar.finance.app.R;
import com.fivestar.finance.app.bean.resp.UserResponse;
import com.fivestar.finance.app.greendao.UserResponseDao;
import com.fivestar.finance.app.ui.BaseSwipeBackActivity;

import org.greenrobot.greendao.query.QueryBuilder;

import butterknife.BindView;

/**
 * 简要描述
 *
 * @author Derek.Kidd
 * @version V1.0.0
 * @date 2016/8/24 9:26
 */
public class MyActivity extends BaseSwipeBackActivity {

    @BindView(R.id.toolbar)
    Toolbar mToolbar;

    @BindView(R.id.collapsing_toolbar_layout)
    CollapsingToolbarLayout mCollapsingToolbarLayout;

    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;

    @BindView(R.id.cat_title)
    TextView tvName;

    @BindView(R.id.subtitle)
    TextView tvPhone;

    @Override
    protected int initContentView() {
        return R.layout.activity_my;
    }

    @Override
    public void initInjector() {


    }


    @Override
    public void initUiAndListener() {
        UserResponseDao userResponseDao = ((FFApplication) getApplication()).getApplicationComponent().getUserResponseDao();
        QueryBuilder<UserResponse> qb = userResponseDao.queryBuilder();
        UserResponse userResponse = qb.where(UserResponseDao.Properties.UserId.eq("10222")).unique();

        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

//        mCollapsingToolbarLayout.setTitle("Derek");
        tvName.setText(userResponse.getName());
        tvPhone.setText(userResponse.getMobile());


        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);

        recyclerView.setAdapter(new MyRecycerViewAdapter());
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isApplyStatusBarColor() {
        return false;
    }
}
